﻿using System;
using System.Drawing;

using BLL;
using Utility;

namespace EvaluationSystem
{
    public partial class ChangePasswordAdmin : System.Web.UI.Page
    {
        private string m_username = string.Empty;

        private AdminUserBLL adminUser = new AdminUserBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteSystemMaster)Master).InitMenu();
            ((SiteSystemMaster)Master).li3.Attributes.Add("class", "hover ccc");
            ((SiteSystemMaster)Master).b_hmenu1.Style.Add("display", "none");
            ((SiteSystemMaster)Master).b_hmenu2.Style.Add("display", "none");
            ((SiteSystemMaster)Master).b_hmenu3.Style.Clear();
            ((SiteSystemMaster)Master).s_menu3_4.Style.Add("COLOR", "#147ab8");
            ((SiteSystemMaster)Master).s_menu3_4.Style.Add("TEXT-DECORATION", "none"); 

            if (Session["username"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script>alert('请先登录系统!');top.location.href='../Enterprise/EnterpriseLogin.aspx';</script>");
                return;
            }
            else
            {
                m_username = Session["username"].ToString();
            }
        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            int result = adminUser.UpdatePassword(m_username, txtNewPwdA.Text.Trim());

            if (result == 1)
            {
                Session["username"] = null;
                MessageBox.ShowAndRedirect(this, "密码修改成功，请使用新密码进行登录!", "Login.aspx");
            }
        }
    }
}